use chrono::NaiveDateTime;
use serde::Serialize;

#[derive(Clone)]
#[derive(Serialize)]
pub struct TodoItem {
    pub id: usize,
    pub content: String,
    pub status: String,
    pub priority: String,
    #[serde(serialize_with = "naive_datetime_serialize")]
    pub created_at: NaiveDateTime,
    #[serde(serialize_with = "naive_datetime_serialize")]
    pub updated_at: NaiveDateTime,
}

// 将 NaiveDateTime 序列化为字符串格式
fn naive_datetime_serialize<S>(date: &NaiveDateTime, serializer: S) -> Result<S::Ok, S::Error>
where
    S: serde::Serializer,
{
    let s = date.format("%Y-%m-%d %H:%M:%S").to_string();
    serializer.serialize_str(&s)
}